package cl.mt.util;

public class HiloEnvioMensaje extends Thread {

    MessageSender messageService;

    public HiloEnvioMensaje(MessageSender emailService) {
        super();
        this.messageService = emailService;
    }

    public void setEmailService(MessageSender emailService) {
        this.messageService = emailService;
    }

    @Override
    public void run() {
        boolean envia = true;
        int i = 0;
        while (envia && i <= 10) {
            i++;
            try {
                messageService.sendMessage();
                envia = false;
            } catch (Exception e) {
                if (i >= 10) {
                    e.printStackTrace();
                }
            }
        }
    }
}
